/* 
 * Track.java
 */
package behavior_analysis_model;

import behavior_analysis_control.DateUtils;

/**
 * Track is an object containing GPS coordinates and a date/time.  Represents
 * a GPS tracking device single record.
 * 
 * @author Sean Brown
 * @version 11/10/2012
 */
public class Track {
	
	/**
	 * Value of this Track's date/time
	 */
	private final long my_date_time;
	
	/**
	 * Latitude value.
	 */
	private final double my_longitude;
	
	/**
	 * Longitude value.
	 */
	private final double my_latitude;
	
	/**
	 * Constructor that allows a long value for time, either for the amount of time
	 * or the time since 1979 origin.
	 * 
	 * @param the_latitude Latitude
	 * @param the_longitude Longitude
	 * @param the_date_time Date/time as a long
	 */
	public Track(final double the_latitude, final double the_longitude, final long the_date_time) {
		my_date_time = the_date_time;
		my_latitude = the_latitude;
		my_longitude = the_longitude;
	}
	
	/**
	 * Getter method for date/time value.
	 * @return date/time long value.
	 */
	public long getDateTime() {
		return my_date_time;
	}
	
	/**
	 * Getter method for longitude.
	 * @return longitude.
	 */
	public double getLongitude() {
		return my_longitude;
	}
	
	/**
	 * Getter method for latitude.
	 * @return latitude.
	 */
	public double getLatitude() {
		return my_latitude;
	}
	
	/**
	 * Clone method which creates a new Track from this Track.
	 * @return Track clone
	 */
	public Track clone() {
		Track t = new Track(my_latitude, my_longitude, getDateTime());
		return t;
	}
	
	/**
	 * Returns a string representation of the latitude/longitude values.
	 * 
	 * @return String representation of GPS coords.
	 */
	public String latLongToString() {
		final StringBuilder sb = new StringBuilder();
		sb.append("Location(Lat,Lon): ");
		sb.append(getLatitude());
		sb.append(", ");
		sb.append(getLongitude());
		return sb.toString();
	}
	
	/**
	 * Returns a string representation of this object.
	 * 
	 * @return String representation of this object.
	 */
	public String toString() {
		final StringBuilder sb = new StringBuilder();
		sb.append(latLongToString());
		sb.append(", Date/Time: ");
		sb.append(DateUtils.dateTimeFormatted(my_date_time));
		return(sb.toString());
	}
	
	/**
	 * Returns an alternative string representation of this object, which
	 * displays the Date/Time in days/hours/minutes/seconds.
	 * 
	 * @return String representation of this object.
	 */
	public String totalTimeToString() {
		final StringBuilder sb = new StringBuilder();
		sb.append("Total time: ");
		sb.append(DateUtils.millisFormatString(getTotalTime()));
		return sb.toString();
	}

	/**
	 * Returns the alternative getter for time when used as
	 * a time keeper for amount of time rather than a date/time stamp.
	 * 
	 * @return
	 */
	public long getTotalTime() {
		return getDateTime();
	}
}
